<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: Origami</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">Origami</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/origami/file_rb.html">
                origami/file.rb
                </a>
        <br />
                <a href="../files/origami/object_rb.html">
                origami/object.rb
                </a>
        <br />
                <a href="../files/origami/outline_rb.html">
                origami/outline.rb
                </a>
        <br />
                <a href="../files/origami/array_rb.html">
                origami/array.rb
                </a>
        <br />
                <a href="../files/origami/acroform_rb.html">
                origami/acroform.rb
                </a>
        <br />
                <a href="../files/origami/parser_rb.html">
                origami/parser.rb
                </a>
        <br />
                <a href="../files/origami/encryption_rb.html">
                origami/encryption.rb
                </a>
        <br />
                <a href="../files/origami/xfa_rb.html">
                origami/xfa.rb
                </a>
        <br />
                <a href="../files/origami/reference_rb.html">
                origami/reference.rb
                </a>
        <br />
                <a href="../files/origami/metadata_rb.html">
                origami/metadata.rb
                </a>
        <br />
                <a href="../files/origami/stream_rb.html">
                origami/stream.rb
                </a>
        <br />
                <a href="../files/origami/actions_rb.html">
                origami/actions.rb
                </a>
        <br />
                <a href="../files/origami/pdf_rb.html">
                origami/pdf.rb
                </a>
        <br />
                <a href="../files/origami/name_rb.html">
                origami/name.rb
                </a>
        <br />
                <a href="../files/origami/numeric_rb.html">
                origami/numeric.rb
                </a>
        <br />
                <a href="../files/origami/string_rb.html">
                origami/string.rb
                </a>
        <br />
                <a href="../files/origami/webcapture_rb.html">
                origami/webcapture.rb
                </a>
        <br />
                <a href="../files/origami/destinations_rb.html">
                origami/destinations.rb
                </a>
        <br />
                <a href="../files/origami/catalog_rb.html">
                origami/catalog.rb
                </a>
        <br />
                <a href="../files/origami/filters_rb.html">
                origami/filters.rb
                </a>
        <br />
                <a href="../files/origami/page_rb.html">
                origami/page.rb
                </a>
        <br />
                <a href="../files/origami/header_rb.html">
                origami/header.rb
                </a>
        <br />
                <a href="../files/origami/obfuscation_rb.html">
                origami/obfuscation.rb
                </a>
        <br />
                <a href="../files/origami/graphics/xobject_rb.html">
                origami/graphics/xobject.rb
                </a>
        <br />
                <a href="../files/origami/graphics/state_rb.html">
                origami/graphics/state.rb
                </a>
        <br />
                <a href="../files/origami/graphics/patterns_rb.html">
                origami/graphics/patterns.rb
                </a>
        <br />
                <a href="../files/origami/graphics/colors_rb.html">
                origami/graphics/colors.rb
                </a>
        <br />
                <a href="../files/origami/graphics/instruction_rb.html">
                origami/graphics/instruction.rb
                </a>
        <br />
                <a href="../files/origami/graphics/path_rb.html">
                origami/graphics/path.rb
                </a>
        <br />
                <a href="../files/origami/graphics/text_rb.html">
                origami/graphics/text.rb
                </a>
        <br />
                <a href="../files/origami/trailer_rb.html">
                origami/trailer.rb
                </a>
        <br />
                <a href="../files/origami/adobe/addressbook_rb.html">
                origami/adobe/addressbook.rb
                </a>
        <br />
                <a href="../files/origami/adobe/header_rb.html">
                origami/adobe/header.rb
                </a>
        <br />
                <a href="../files/origami/font_rb.html">
                origami/font.rb
                </a>
        <br />
                <a href="../files/origami/null_rb.html">
                origami/null.rb
                </a>
        <br />
                <a href="../files/origami/docmdp_rb.html">
                origami/docmdp.rb
                </a>
        <br />
                <a href="../files/origami/dictionary_rb.html">
                origami/dictionary.rb
                </a>
        <br />
                <a href="../files/origami/export_rb.html">
                origami/export.rb
                </a>
        <br />
                <a href="../files/origami/xreftable_rb.html">
                origami/xreftable.rb
                </a>
        <br />
                <a href="../files/origami/linearization_rb.html">
                origami/linearization.rb
                </a>
        <br />
                <a href="../files/origami/annotations_rb.html">
                origami/annotations.rb
                </a>
        <br />
                <a href="../files/origami/boolean_rb.html">
                origami/boolean.rb
                </a>
        <br />
                <a href="../files/origami/signature_rb.html">
                origami/signature.rb
                </a>
        <br />
                <a href="../files/origami/functions_rb.html">
                origami/functions.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Module for parsing/generating <a href="Origami/PDF.html">PDF</a> files.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000002">parse</a>&nbsp;&nbsp;
      <a href="#M000003">to_hex</a>&nbsp;&nbsp;
      <a href="#M000004">value</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">

    <div id="class-list">
      <h3 class="section-bar">Classes and Modules</h3>

      Module <a href="Origami/Adobe.html" class="link">Origami::Adobe</a><br />
Module <a href="Origami/Colors.html" class="link">Origami::Colors</a><br />
Module <a href="Origami/Configurable.html" class="link">Origami::Configurable</a><br />
Module <a href="Origami/Destination.html" class="link">Origami::Destination</a><br />
Module <a href="Origami/Encryption.html" class="link">Origami::Encryption</a><br />
Module <a href="Origami/Field.html" class="link">Origami::Field</a><br />
Module <a href="Origami/Filter.html" class="link">Origami::Filter</a><br />
Module <a href="Origami/Function.html" class="link">Origami::Function</a><br />
Module <a href="Origami/Graphics.html" class="link">Origami::Graphics</a><br />
Module <a href="Origami/HintTable.html" class="link">Origami::HintTable</a><br />
Module <a href="Origami/Number.html" class="link">Origami::Number</a><br />
Module <a href="Origami/Obfuscator.html" class="link">Origami::Obfuscator</a><br />
Module <a href="Origami/Object.html" class="link">Origami::Object</a><br />
Module <a href="Origami/ResourcesHolder.html" class="link">Origami::ResourcesHolder</a><br />
Module <a href="Origami/Signature.html" class="link">Origami::Signature</a><br />
Module <a href="Origami/String.html" class="link">Origami::String</a><br />
Module <a href="Origami/Text.html" class="link">Origami::Text</a><br />
Module <a href="Origami/UsageRights.html" class="link">Origami::UsageRights</a><br />
Module <a href="Origami/Webcapture.html" class="link">Origami::Webcapture</a><br />
Module <a href="Origami/XDP.html" class="link">Origami::XDP</a><br />
Module <a href="Origami/XFA.html" class="link">Origami::XFA</a><br />
Class <a href="Origami/Action.html" class="link">Origami::Action</a><br />
Class <a href="Origami/Annotation.html" class="link">Origami::Annotation</a><br />
Class <a href="Origami/Array.html" class="link">Origami::Array</a><br />
Class <a href="Origami/Boolean.html" class="link">Origami::Boolean</a><br />
Class <a href="Origami/ByteString.html" class="link">Origami::ByteString</a><br />
Class <a href="Origami/Catalog.html" class="link">Origami::Catalog</a><br />
Class <a href="Origami/CatalogAdditionalActions.html" class="link">Origami::CatalogAdditionalActions</a><br />
Class <a href="Origami/ContentStream.html" class="link">Origami::ContentStream</a><br />
Class <a href="Origami/DeveloperExtension.html" class="link">Origami::DeveloperExtension</a><br />
Class <a href="Origami/Dictionary.html" class="link">Origami::Dictionary</a><br />
Class <a href="Origami/EmbeddedFileParameters.html" class="link">Origami::EmbeddedFileParameters</a><br />
Class <a href="Origami/EmbeddedFileStream.html" class="link">Origami::EmbeddedFileStream</a><br />
Class <a href="Origami/Encoding.html" class="link">Origami::Encoding</a><br />
Class <a href="Origami/Extensions.html" class="link">Origami::Extensions</a><br />
Class <a href="Origami/ExternalFile.html" class="link">Origami::ExternalFile</a><br />
Class <a href="Origami/ExternalStream.html" class="link">Origami::ExternalStream</a><br />
Class <a href="Origami/FileSpec.html" class="link">Origami::FileSpec</a><br />
Class <a href="Origami/Filename.html" class="link">Origami::Filename</a><br />
Class <a href="Origami/Font.html" class="link">Origami::Font</a><br />
Class <a href="Origami/FontDescriptor.html" class="link">Origami::FontDescriptor</a><br />
Class <a href="Origami/FontStream.html" class="link">Origami::FontStream</a><br />
Class <a href="Origami/HexaString.html" class="link">Origami::HexaString</a><br />
Class <a href="Origami/HintStream.html" class="link">Origami::HintStream</a><br />
Class <a href="Origami/Integer.html" class="link">Origami::Integer</a><br />
Class <a href="Origami/InteractiveForm.html" class="link">Origami::InteractiveForm</a><br />
Class <a href="Origami/InvalidPDFInstructionError.html" class="link">Origami::InvalidPDFInstructionError</a><br />
Class <a href="Origami/InvalidXRefStreamObjectError.html" class="link">Origami::InvalidXRefStreamObjectError</a><br />
Class <a href="Origami/Linearization.html" class="link">Origami::Linearization</a><br />
Class <a href="Origami/Metadata.html" class="link">Origami::Metadata</a><br />
Class <a href="Origami/MetadataStream.html" class="link">Origami::MetadataStream</a><br />
Class <a href="Origami/Name.html" class="link">Origami::Name</a><br />
Class <a href="Origami/NameLeaf.html" class="link">Origami::NameLeaf</a><br />
Class <a href="Origami/NameTreeNode.html" class="link">Origami::NameTreeNode</a><br />
Class <a href="Origami/Names.html" class="link">Origami::Names</a><br />
Class <a href="Origami/Null.html" class="link">Origami::Null</a><br />
Class <a href="Origami/ObjectStream.html" class="link">Origami::ObjectStream</a><br />
Class <a href="Origami/Outline.html" class="link">Origami::Outline</a><br />
Class <a href="Origami/OutlineItem.html" class="link">Origami::OutlineItem</a><br />
Class <a href="Origami/PDF.html" class="link">Origami::PDF</a><br />
Class <a href="Origami/Page.html" class="link">Origami::Page</a><br />
Class <a href="Origami/PageAdditionalActions.html" class="link">Origami::PageAdditionalActions</a><br />
Class <a href="Origami/PageTreeNode.html" class="link">Origami::PageTreeNode</a><br />
Class <a href="Origami/Perms.html" class="link">Origami::Perms</a><br />
Class <a href="Origami/Real.html" class="link">Origami::Real</a><br />
Class <a href="Origami/Rectangle.html" class="link">Origami::Rectangle</a><br />
Class <a href="Origami/Reference.html" class="link">Origami::Reference</a><br />
Class <a href="Origami/Resources.html" class="link">Origami::Resources</a><br />
Class <a href="Origami/Stream.html" class="link">Origami::Stream</a><br />
Class <a href="Origami/String.html" class="link">Origami::String</a><br />
Class <a href="Origami/Trailer.html" class="link">Origami::Trailer</a><br />
Class <a href="Origami/URL.html" class="link">Origami::URL</a><br />
Class <a href="Origami/ViewerPreferences.html" class="link">Origami::ViewerPreferences</a><br />
Class <a href="Origami/XRef.html" class="link">Origami::XRef</a><br />
Class <a href="Origami/XRefStream.html" class="link">Origami::XRefStream</a><br />
Class <a href="Origami/XRefToCompressedObj.html" class="link">Origami::XRefToCompressedObj</a><br />

    </div>

    <div id="constants-list">
      <h3 class="section-bar">Constants</h3>

      <div class="name-list">
        <table summary="Constants">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">VERSION</td>
          <td>=</td>
          <td class="context-item-value">&quot;1.0.0-beta3&quot;</td>
        </tr>
        </table>
      </div>
    </div>



      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000002" class="method-detail">
        <a name="M000002"></a>

        <div class="method-heading">
          <a href="#M000002" class="method-signature">
          <span class="method-name">parse</span><span class="method-args">(file, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000002-source">
<pre>
     <span class="ruby-comment cmt"># File origami/parser.rb, line 90</span>
 90:   <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Origami</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">file</span>, <span class="ruby-identifier">options</span> = {})
 91:     
 92:     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">file</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:read</span>)
 93:       <span class="ruby-identifier">filename</span> = <span class="ruby-keyword kw">nil</span>
 94:       <span class="ruby-identifier">data</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">read</span>
 95:     <span class="ruby-keyword kw">else</span>
 96:       <span class="ruby-identifier">filename</span> = <span class="ruby-identifier">file</span>
 97:       <span class="ruby-identifier">data</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-value str">&quot;r&quot;</span>).<span class="ruby-identifier">binmode</span>.<span class="ruby-identifier">read</span>
 98:     <span class="ruby-keyword kw">end</span>
 99:     
100:     <span class="ruby-identifier">stream</span> = <span class="ruby-constant">StringScanner</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">data</span>)
101:     
102:     <span class="ruby-identifier">hdr</span> = <span class="ruby-keyword kw">nil</span>
103:     [ <span class="ruby-constant">PDF</span>, <span class="ruby-constant">Adobe</span><span class="ruby-operator">::</span><span class="ruby-constant">AddressBook</span> ].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">filetype</span><span class="ruby-operator">|</span>
104:       <span class="ruby-keyword kw">begin</span>
105:         <span class="ruby-identifier">hdr</span> = <span class="ruby-identifier">filetype</span><span class="ruby-operator">::</span><span class="ruby-constant">Header</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">stream</span>)
106:         <span class="ruby-keyword kw">break</span>
107:       <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span> 
108:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">filetype</span> <span class="ruby-operator">==</span> <span class="ruby-constant">PDF</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:force</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>
109:           <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">stream</span>.<span class="ruby-identifier">skip_until</span>(<span class="ruby-regexp re">/%PDF-/</span>).<span class="ruby-identifier">nil?</span>
110:             <span class="ruby-identifier">stream</span>.<span class="ruby-identifier">pos</span> = <span class="ruby-identifier">stream</span>.<span class="ruby-identifier">pos</span> <span class="ruby-operator">-</span> <span class="ruby-value">5</span>
111:             <span class="ruby-keyword kw">retry</span>
112:           <span class="ruby-keyword kw">end</span>
113:         <span class="ruby-keyword kw">end</span>
114: 
115:         <span class="ruby-keyword kw">next</span>
116:       <span class="ruby-keyword kw">end</span>
117:     <span class="ruby-keyword kw">end</span>
118:     
119:     <span class="ruby-identifier">parser</span> = 
120:     <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">hdr</span>
121:       <span class="ruby-keyword kw">when</span> <span class="ruby-constant">PDF</span><span class="ruby-operator">::</span><span class="ruby-constant">Header</span>
122:         <span class="ruby-constant">PDF</span><span class="ruby-operator">::</span><span class="ruby-constant">LinearParser</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>)     
123:       <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Adobe</span><span class="ruby-operator">::</span><span class="ruby-constant">AddressBook</span><span class="ruby-operator">::</span><span class="ruby-constant">Header</span>
124:         <span class="ruby-constant">Adobe</span><span class="ruby-operator">::</span><span class="ruby-constant">AddressBook</span><span class="ruby-operator">::</span><span class="ruby-constant">Parser</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>)
125:       <span class="ruby-keyword kw">else</span>
126:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">ParsingError</span>, <span class="ruby-value str">&quot;No file type was recognized&quot;</span>
127:     <span class="ruby-keyword kw">end</span>
128: 
129:     <span class="ruby-identifier">parsee</span> = <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">stream</span>)
130:     
131:     <span class="ruby-identifier">parsee</span>.<span class="ruby-identifier">filename</span> = <span class="ruby-identifier">filename</span>
132:     <span class="ruby-identifier">parsee</span>
133:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000003" class="method-detail">
        <a name="M000003"></a>

        <div class="method-heading">
          <a href="#M000003" class="method-signature">
          <span class="method-name">to_hex</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Converts self to <a href="Origami/HexaString.html">HexaString</a>
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000003-source">
<pre>
     <span class="ruby-comment cmt"># File origami/string.rb, line 342</span>
342:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_hex</span>
343:       <span class="ruby-constant">HexaString</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">value</span>)
344:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000004" class="method-detail">
        <a name="M000004"></a>

        <div class="method-heading">
          <a href="#M000004" class="method-signature">
          <span class="method-name">value</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000004-source">
<pre>
     <span class="ruby-comment cmt"># File origami/string.rb, line 346</span>
346:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">value</span>
347:       <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">decrypt!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Encryption</span><span class="ruby-operator">::</span><span class="ruby-constant">EncryptedString</span>) <span class="ruby-keyword kw">and</span> <span class="ruby-keyword kw">not</span> <span class="ruby-ivar">@decrypted</span>
348: 
349:       <span class="ruby-identifier">to_str</span>
350:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>